﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using TS_XY_Train_Repaire.ToolSystem;

namespace Tool_System_Client
{
    public partial class OrderDetail_Form : DevExpress.XtraEditors.XtraForm
    {
        public TS_Order m_oOrder = new TS_Order();

        public OrderDetail_Form()
        {
            InitializeComponent();
        }

        private void OrderDetail_Form_Load(object sender, EventArgs e)
        {
            Color colorCaption = Color.FromArgb(219, 219, 219);
            lc_caption1.ForeColor = colorCaption;
            lc_caption2.ForeColor = colorCaption;
            lc_caption3.ForeColor = colorCaption;
            lc_caption4.ForeColor = colorCaption;
            lc_caption5.ForeColor = colorCaption;
            lc_caption6.ForeColor = colorCaption;
            lc_caption7.ForeColor = colorCaption;
            lc_caption8.ForeColor = colorCaption;

            lc_orderid.Text = m_oOrder.IID.ToString();
            lc_orderid.Text = m_oOrder.IID.ToString();
            lc_proposname.Text = m_oOrder.SProposName;
            if (m_oOrder.SProposTime != DateTime.MinValue)
                lc_propostime.Text = m_oOrder.SProposTime.ToString();
            lc_sendname.Text = m_oOrder.SSendName;
            if (m_oOrder.SSendTime != DateTime.MinValue)
                lc_sendtime.Text = m_oOrder.SSendTime.ToString();
            lc_recivename.Text = m_oOrder.SReciveName;
            if (m_oOrder.SReciveTime != DateTime.MinValue)
                lc_receivetime.Text = m_oOrder.SReciveTime.ToString();
            lc_orderstatus.Text = Utility.GetOrderStateString(m_oOrder.IStatus);

            if (m_oOrder.IStatus == OrderStatus.Confirm)
            {
                foreach (Button btn in windowsUIButtonPanel1.Buttons)
                {
                    btn.Visible = true;
                }
            }

            InitData();
        }

        private void windowsUIButtonPanel1_ButtonClick(object sender, DevExpress.XtraBars.Docking2010.ButtonEventArgs e)
        {
            if (e.Button.Properties.Caption == "返回")
            {
                this.DialogResult = DialogResult.OK;
            }
        }

        private void InitData()
        {
            DataTable dt = DBManager.GetInstance().GetOrderDetail(m_oOrder.IID);
            gridControl1.DataSource = dt;
        }
    }
}